<template>
  <div class="bj_box">
    <header-comm></header-comm>
    <div class="header_sele" :style="$parent.$parent.collapsed==false?'left: 10%':'left:80px'">
      <div class="add_qy"></div>
      <div>
        <div class="list_head">
          <div class="fl_right">
            <a-checkbox-group :options="plainOptions" v-model="checkedList" @change="checkChange" />
          </div>
        </div>
        <div class="gl_tjwz" v-if="$store.state.tjwz">
          <bjtk class="gl_tjym"></bjtk>
        </div>
        <div class="gl_tjwz" v-if="$store.state.bjlstk">
          <bjlstk class="gl_tjym"></bjlstk>
        </div>
        <div class="seach">
          <div class="sele">
            <a-input placeholder="请输入型号或者品牌 " style="width: 250px" @change="onSearch" />
            <a-icon type="search" class="search" />
          </div>
        </div>
      </div>
    </div>
    <!-- 表格-================= -->
    <div class="bcg">
      <div class="glwz">
        <!-- <xzl v-if="$store.state.xzlflg"></xzl> -->
        <a-table
          @change="handleChangelist"
          :loading="loading"
          :columns="columns"
          :pagination="pagination"
          :dataSource="data"
        :scroll="{ x: 1700}"
          
        >
          <tr slot="expandedRowRender" slot-scope="record">
            <!-- <span class="xj">
              <span class="spantit">询价公司：</span>
              {{record.xjgsmc}}
            </span>
            <span class="xj">
              <span class="spantit">询价人：</span>
              {{record.xjr}}
            </span>
            <span class="xj">
              <span class="spantit">询价人手机：</span>
              {{record.lxdh}}
            </span> -->
            <span class="xj">
              <span class="spantit">备注：</span>
              {{record.mxbz}}
            </span>
          </tr>
          <template slot="sfgq" slot-scope="text,record,index">
            <span>
              <a-tag v-if="text =='报价中'" color="red">{{text}}</a-tag>
              <a-tag v-if="text =='已过期'" color="#ccc">{{text}}</a-tag>
            </span>
          </template>

          <template slot="xjgsmc" slot-scope="text,record,index">
            <span>
             {{record.xjgsmc}}
            </span>
          </template>
          <template slot="xjr" slot-scope="text,record,index">
            <span>
               {{record.xjr}}
            </span>
          </template>
          <template slot="lxdh" slot-scope="text,record,index">
            <span>
               {{record.lxdh}}
            </span>
          </template>



          <template slot="sldw" slot-scope="text,record,index">
            <span>
              <span style="color:red;">{{record.sl}}</span>
              {{record.jldw}}
            </span>
          </template>
          <template v-for="titletext in []" :slot="titletext" slot-scope="text,record,index">
            <div :key="titletext"></div>
          </template>

          <template slot="operation" slot-scope="text,record,index">
            <div class="editable-row-operations">
              <a class="del" @click="()=>bj(record,record.key)">报价</a>
              <a-badge :showZero="true" :count="record.bjs" v-if="record.bjs>0">
                <a
                  href="#"
                  style="margin-right:17px;"
                  @click="()=>bjls(record,record.key)"
                  class="head-example"
                >报价历史</a>
              </a-badge>
              <a
                href="#"
                style="margin-right:17px;"
                v-else
                @click="()=>bjls(record,record.key)"
                class="head-example"
              >报价历史</a>
              <span v-if="record.djzt!='全公开'" class="systyle">
                <span class="sitit">私有</span>
              </span>
            </div>
          </template>
        </a-table>
      </div>
    </div>
  </div>
</template>

<script>
import qs from "qs";
import headerComm from "../header-comm/header.vue";
import bjtk from "./bjtk.vue";
import bjlstk from "./bjls.vue";
const columns = [
  {
    title: "询价日期",
    dataIndex: "xjrq"
  },
  {
    title: "型号",
    dataIndex: "gg"
  },
  {
    title: "品牌",
    dataIndex: "pp"
  },
  {
    title: "数量",
    dataIndex: "sldw",
    scopedSlots: { customRender: "sldw" }
  },

  {
    title: "要求货期",
    dataIndex: "yqdhq"
  },
  {
    title: "状态",
    dataIndex: "sfgq",
    scopedSlots: { customRender: "sfgq" }
  },
  {
    title: "询价公司",
    dataIndex: "xjgsmc",
    scopedSlots: { customRender: "xjgsmc" }
  },
  {
    title: "询价人",
    dataIndex: "xjr",
    scopedSlots: { customRender: "xjr" }
  },
  {
    title: "询价人手机",
    dataIndex: "lxdh",
    scopedSlots: { customRender: "lxdh" }
  },
  {
    title: "交货地",
    dataIndex: "jhd"
  },

  {
    title: "操作",
    dataIndex: "operation",
    scopedSlots: { customRender: "operation" },
    fixed:'right',
    width:180
  }
];
const data = [];
const plainOptions = ["私有询价", "云询价"];
const defaultCheckedList = ["私有询价", "云询价"];
export default {
  data() {
    this.cacheData = data.map(item => ({ ...item }));
    return {
      data,
      columns,
      sele: "",
      serchvalue: "",
      pagination: {
        defaultPageSize: 10,
        showTotal: total => `共 ${total} 条数据`,
        total: 0
      },
      loading: true,
      datakh: [],
      khvalue: "",
      selectedRowKeys: [],
      fyflag: false,
      checkedList: defaultCheckedList,
      plainOptions
    };
  },
  components: {
    headerComm,
    bjtk,
    bjlstk
  },
  methods: {
    //私有或云询
    checkChange() {
      this.handleChangelist(this.pagination, this.serchvalue, this.checkedList);
    },
    //搜索框
    onSearch(e) {
      this.serchvalue = e.target.value;
      this.handleChangelist(this.pagination, this.serchvalue, this.checkedList);
    },

    //报价列表
    handleChangelist(pagination) {
      this.loading = true;
      this.axios
        .post(
          "baojia/BaojiaList.php",
          qs.stringify({
            page: pagination.current,
            pageSize: pagination.defaultPageSize,
            phone: this.$store.state.bbl_phone,
            sqdwid: this.$store.state.bbl_sqdwid,
            djzt: this.checkedList,
            ggpp: this.serchvalue
          })
        )
        .then(res => {
          console.log(res);
          this.loading = false;
          if (res.data.code == 303) {
            this.data = res.data.result.data;
            this.pagination.total = Number(res.data.result.total);
            this.cacheData = this.data.map(item => ({
              ...item
            }));
            for (var i = 0; i < res.data.result.data.length; i++) {
              this.data[i].key = res.data.result.data[i].id_num;
              this.data[i].sfgq = res.data.result.data[i].sfgq.trim();
              this.data[i].djzt = res.data.result.data[i].djzt.trim();
            }
          } else {
            this.data = [];
          }
        });
    },

    //报价
    bj(value, key) {
      console.log(value)
      this.$store.state.tjwz = true;
      this.$store.state.bjdata = value;
    },
    //报价历史
    bjls(value, key) {
      this.$store.state.bjlstk = true;
      this.$store.state.xjxh = value.xjxh;
    }
  },

  created() {
    this.handleChangelist(this.pagination);
    $(
      ".ant-table-row-expand-icon-cell>.ant-table-row-expand-icon ant-table-row-collapsed"
    ).text("更多");
  }
};
</script>

<style lang='less' >
.ant-table-row-expand-icon-cell {
  width: 90px !important;
}
// .ant-table-row-collapsed::before{
//      content: '+'!important;
//          padding: 4px;
// }
// .ant-table-row-collapsed::after{
//      content: '更多'!important;
//          color: #ee6300;
//     margin-left: 6px;
// }
.bj_box {
  .gl_tjwz {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999999;
    height: 930px;

    .gl_tjym {
      position: absolute;
      width: 80%;
      left: 50%;
      transform: translateX(-50%);
    }
  }

  .header_sele {
    position: absolute;
    top: 55px;
    left: 200px;
    z-index: 999;
    text-align: right;
    width: 90%;
    background-color: #fff;
    box-shadow: 5px 5px 5px #ccc;
    // height: 50px;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .seach {
      display: inline-block;

      .sele {
        position: relative;

        i {
          position: absolute;
          top: 10px;
          right: 8px;
        }
      }
    }

    .list_head {
      display: inline-block;

      .tit {
        font-size: 16px;
      }

      padding: 10px 15px;

      .fl_right {
        .margin {
          margin: 0 5px;
        }

        .xzl_btn:hover {
          border: 0 !important;
          color: #fff !important;
          background: #1890ff !important;
        }
      }
    }
  }

  .glwz {
    width: 98%;
    position: absolute;
    top: 147px;
    left: 1%;
    background-color: #fff;
    border: 1px solid #ccc;

    .ant-table-thead > tr,
    .ant-table-tbody > tr {
      height: 50px !important;
    }
    .ant-table-tbody tr td {
      position: relative !important;
    }

    .xj {
      margin: 0 20px 0 10px;
      .spantit {
        font-weight: bold;
        font-size: 15px;
      }
    }

    .del {
      .bjnum {
        color: #999;
      }
    }
  }

  .ant-spin-nested-loading > div > .ant-spin {
    top: 100px !important;
  }

  .del {
    padding-right: 15px;
    color: #40a9ff;
    cursor: pointer;
  }
  .ant-table-tbody > tr > td {
    position: relative !important;
  }
  .systyle {
    position: absolute;
    display: inline-block;
    width: 40px;
    height: 40px;
    background-color: #1890ff;
    top: 0;
    right: 0;
    border-width: 0px 40px 40px 0px;
    border-style: solid;
    border-color: transparent transparent #fff;
    .sitit {
      position: absolute;
      top: 0;
      left: 12px;
      width: 30px;
      color: #fff;
      font-size: 12px;
    }
  }
}
</style>
